﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace LightSO.CMS.Model.EasyUI
{
    public class Tabs : ModelBase
    {
        /// <summary>
        /// 构造方法
        /// </summary>
        protected Tabs()
        {
            Buttons = new Dictionary<string, Tab>();
        }
        public static Tabs Create(dynamic ViewBag)
        {
            var tabs = new Tabs();
            ViewBag.Tabs = tabs;

            return tabs;
        }

        public void Add(Tab tab)
        {
            if (tab == null || string.IsNullOrWhiteSpace(tab.Id))
                return;

            Buttons.Add(tab.Id, tab);
        }

        /// <summary>
        /// Tabs列表
        /// </summary>
        public Dictionary<string, Tab> Buttons { get; set; }


        /// <summary>
        /// 引用脚本路径
        /// </summary>
        public string ScriptSrc { get; set; }

        /// <summary>
        /// 选中事件执行的Javascript脚本
        /// </summary>
        public string OnSelect { get; set; }
    }

    public class Tab : Button
    {
        /// <summary>
        /// Tab的构造方法
        /// </summary>
        /// <param name="id">表格Id</param>
        /// <param name="title">显示名称</param>
        public Tab(string id, string title, string icon = "", string url = "")
            : base(id, title, string.Empty, icon)
        {
            base.Url = url;
        }
    }
}